package com.icedbrew.appfuel.persistence.entity;

import com.icedbrew.appfuel.util.StringUtil;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;

/**
 * An entity used to categorise application options.
 *
 * @see ApplicationOption
 * @author
 */
@Entity
@Table(name = "application_option_types")
public class ApplicationOptionType extends BaseEntity {

	@Column(name = "code", length = 75, nullable = false, unique = true)
	private String code = StringUtil.EMPTY_STRING;

	@Column(name = "name", length = 125, nullable = false)
	private String name = StringUtil.EMPTY_STRING;

	@Lob
	@Column(name = "description")
	private String description = StringUtil.EMPTY_STRING;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public final boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof ApplicationOptionType)) return false;
		if (!super.equals(o)) return false;

		ApplicationOptionType that = (ApplicationOptionType) o;

		if (!code.equals(that.code)) return false;

		return true;
	}

	@Override
	public final int hashCode() {
		int result = super.hashCode();
		result = 31 * result + code.hashCode();
		return result;
	}
}
